package yanivosher.aiproject;

import java.util.LinkedList;

public class AStarState implements Comparable<AStarState>{
	int HeuristicCost = Integer.MAX_VALUE;
	int CostFromStart = Integer.MAX_VALUE;
	Graph graph;
	public Vertex vertex = null;
	public AStarState previous = null;
	
	
	public AStarState(Vertex vertex,AStarState previous,Graph graph) {
		this.vertex = vertex;
		this.previous = previous;
		this.graph = graph;
	}
	
	public void calculateHeuristicValue(Vertex destination) {
		LinkedList<Vertex> trip = DijkstraAlgorithm.getShortestPath(Environment.getInstance().graph,this.vertex,destination);
		this.HeuristicCost = Environment.getInstance().graph.getPathCost(trip)*2;
		System.out.println("vertext "+vertex.getId() + "HeuristicCost = " + this.HeuristicCost);
	}

	@Override
	public int compareTo(AStarState o) {
		if (o.HeuristicCost > this.HeuristicCost)
			return 1;
		else if(o.HeuristicCost > this.HeuristicCost)
			return -1;
		else 
			return 0;
	}
}
